<template>
  <div class="toutiao">
    <div class="img-wrapper">
      <img  src="https://pic.nximg.cn/file/20181203/19364347_092157561000_2.jpg" alt="">
    </div>
    <div class="content-wrapper">
      <div class="item" v-for="t of toutiaoNews">
        <div class="left">
          <img :src="t.thumbnail_pic_s" alt="">
        </div>
        <div class="right">
          <h1 class="title">{{t.title}}</h1>
          <div class="text-wrapper">
            <span class="category-text">{{t.category}}</span><br>
            <span class="date-text">{{t.date}}</span>
          </div>
        </div>
      </div>
    </div>
<!--    <img alt="Vue logo" src="../assets/logo.png">-->
<!--    <HelloWorld msg="Welcome to Your Vue.js App"/>-->
  </div>
</template>


<script>
import axios from "axios";
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'

export default {
  name: 'toutiao_news',
  data(){
    return{
      toutiaoNews:[]
    }
  },
  methods:{
    _initToutiaoNews() {
      // 发送ajax请求拿新闻数据
      axios.get('/juheNews', {
        params:
            {key: "4135b84f2fb1c6331132def3a993bfdf"}
        // 4135b84f2fb1c6331132def3a993bfdf
      }).then(res => {
        if (res.data.error_code == 0) {
          this.toutiaoNews = res.data.result.data;
          console.log(this.toutiaoNews)
        } else {
          alert('请求失败')
        }
      })
    }
  },
  created() {
    this._initToutiaoNews()
  }
}
</script>

<style scoped lang="stylus">
.toutiao
  .img-wrapper
    width 100%
    height 100px
    img
      width 100%
      height 100%
  .content-wrapper
    margin-top 20px
    .item
      display flex
      width 100%
      height 70px
      padding 4px 0
      border-bottom 1px dotted #2d3a4b
      .left
        width 90px
        height 70px
        img
          width 90px
          height 70px
      .right
        display flex
        flex-wrap wrap
        align-content space-between
        box-sizing border-box
        padding-left 15px
        padding-bottom 15px
        //.title
        // font-size 15px
        .text-wrapper
          //margin-bottom  50px
          margin-left 90px

          //display flex
          //justify-content flex-end
</style>
